package com.ujoku.context.constants;

/**
 * Created by Greg.Chen on 2015/3/2.
 */
public class MessageConstants {
    public final static String SENDER_IM = "im";
    public final static String SENDER_SERVICE = "service";

    public final static String SHIPPED = "shipped";
    public final static String SHIPPED_MESSAGE = "您的订单%s已发货";

    public final static String FRIEND_APPLY = "friendApply";
    public final static String FRIEND_APPLY_MESSAGE = "%s申请添加您为好友";

    public final static String FRIEND_ACCEPT = "friendAccept";
    public final static String FRIEND_ACCEPT_MESSAGE = "%s同意了您的好友申请并成为您的好友";

    public final static String FRIEND_CANCEL = "friendCancel";
    public final static String FRIEND_CANCEL_MESSAGE = "%s取消了与您的好友关系";

    public final static String REPURCHASE = "repurchase";
    public final static String REPURCHASE_MESSAGE = "您申请回购的商品更新了信息";

    public final static String SOLD = "sold";
    public final static String SOLD_MESSAGE = "您的私人酒窖卖出了%s商品%s件";

    public final static String TRANSFER_SUCCESS = "transferS";
    public final static String TRANSFER_SUCCESS_MESSAGE = "您的银行账户%s已经转入%s元,请注意查收";

    public final static String TRANSFER_CANCEL = "transferC";
    public final static String TRANSFER_CANCEL_MESSAGE = "您的转账申请%s未通过,余额已经退回您的账户";

    public final static String APPLY = "apply";
    public final static String APPLY_MESSAGE = "%s申请购买您的%s商品";

    public static String getMessage(String type,String[] value){
        switch (type){
            case SHIPPED :
                return String.format(SHIPPED_MESSAGE, value);

            case FRIEND_APPLY :
                return String.format(FRIEND_APPLY_MESSAGE, value);

            case FRIEND_ACCEPT :
                return String.format(FRIEND_ACCEPT_MESSAGE,value);

            case FRIEND_CANCEL :
                return String.format(FRIEND_CANCEL_MESSAGE,value);

            case REPURCHASE :
                return REPURCHASE_MESSAGE;

            case SOLD :
                return String.format(SOLD_MESSAGE, value);

            case TRANSFER_SUCCESS:
                return String.format(TRANSFER_SUCCESS_MESSAGE, value);

            case TRANSFER_CANCEL:
                return String.format(TRANSFER_CANCEL_MESSAGE, value);

            case APPLY:
                return String.format(APPLY_MESSAGE, value);
        }

        return null;
    }

    public static String getSender(String type){

        boolean cond = FRIEND_ACCEPT.equals(type) || FRIEND_CANCEL.equals(type) || FRIEND_APPLY.equals(type);

        if(cond)
            return SENDER_IM;

        return SENDER_SERVICE;
    }
}
